<html>

<head>
 <link rel="stylesheet" type="text/css" href="doc-styles.css"></link>
 <title>glScript Overview</title> 
</head>

<body>
<h3>glScript Overview</h3>

<a href="index.html">Index</a>

<h4>Contents</h4>
<ul>
<li><a href="#glscript_overview">glScript Overview</a></li>
<li><a href="#glscript_extensions_overview">glScript Extensions Overview</a></li>
<li><a href="#how_glscript_works">How does glScript Work?</a></li>
</ul>

<a name="glscript_overview"><h4>glScript Overview</h4></a>

<!-- glScript Overview -->
<p>
<i>glScript</i> is a script driven OpenGL toolkit. It is a tool that lets you run OpenGL programs written 
in existing scripting languages like JavaScript, VB Script and view its output. It also provides support 
for creating and integrating your own libraries for graphics programming and animation. You can either use 
OpenGL APIs directly from your script or use library APIs for rendering graphics and animation. glScript 
can be used for 2D/3D graphics applications based on OpenGL. It is a useful tool for anyone interested in 
3D graphics programming, OpenGL in particular. It can also be useful for advanced OpenGL programmers for
testing their code without any need to write a compiled OpenGL program in C/C++.
</p>
<p>
<i>With glScript, there are no headers to include, no libraries to link, just script and go :-)</i>
</p>
<!-- glScript Overview end -->

<!-- glScript Extensions -->
<a name="glscript_extensions_overview"><h4>glScript Extensions Overview</h4></a>
<p>
glScript extensions are plug-ins or modules that can be loaded dynamically and used by your scripts.
Extensions are compiled executables that can be easily integrated with glScript engine to 
extend its functionality. Different extensions can provide different capabilities based on requirements. 
<i>Library extension</i>, for example, can provide a set of functions that can be called from your scripts.
<i>GUI plugin</i> extension can be loaded in a development application to extend its features. 
<i>Renderer extension</i> will provide certain interfaces that allows glScript engine to
draw graphics and perform animations natively rather than through scripts. 
</p>
<p>
You can create your own extensions and use them in your scripts. 
</p>
<!-- glScript Extensions end -->


<!-- How glScript works -->
<a name="how_glscript_works"><h4>How does glScript Work?</h4></a>
<p>
Nice thing about glScript is that it is designed to support any scripting language
based on ActiveScript. ActiveScript is a technology based on COM (Component Object Model) for scripting engines 
to work under Windows platform. Any scripting engine, which is ActiveScript compliant, can be used with glScript. 
This means you can focus in learning OpenGL instead of learning a specific language. This was one of the primary 
goals in the design of glScript. That said; let us see how it actually works?
</p>

<p>
Each scripting language will have its own parser / interpreter known as scripting engine.
glScript can automatically determine which scripting engine to use based on the extension name you
give to your script files. glScript engine loads the appropriate engine and hands over the script
source for its real execution. The question is then how does a scripting engine understand OpenGL APIs. 
Since scripting engines do not have any interfaces for invoking OpenGL APIs, it cannot. Scripting engines,
however, provides a way for script hosts to plug in or add their own interfaces before it executes the script. 
glScript engine adds OpenGL interface to the scripting engine and makes it available so that you can invoke 
the OpenGL APIs right from your script. Besides the OpenGL interface, glScript engine also adds its own interfaces
for other aspects like environment configuration and custom libraries.
</p>

<p>glScript program scripts are executed in two different phases.</p>
<ul>
<li>Configuration phase</li>
<li>Render phase</li>
</ul>

<p>
Whenever a script source is loaded from a file, it is passed over to the associated script 
engine for parsing. Syntax errors can be detected by the script engine at this time, in which
case the script is terminated. If everything is fine, the script is executed in configuration mode.
In this  mode, you can initialize various settings like window size, view port, animation, desired 
frame rate etc.
</p>

<p>
Once the configuration phase is done without any error, render phase is executed.
In the render phase, glScript engine first calls the <code>gls_init</code> event on your script. The script may
initialize OpenGL environment settings in this event. For e.g. lightings could be enabled.
The script may also initialize models and scene graph if native drawing mode is set. glScript engine then 
calls <code>gls_renderScene</code> event on your script to draw the scene. If animation is enabled in the configuration phase, 
glScript engine starts a timer and calls <code>gls_renderScene</code> for each frame otherwise only once. If native drawing mode is
set to true in the configuration phase, <code>gls_renderScene</code> will never be called on your script. In this case, 
native functions in the renderer extension are called to draw the scene. You can load a renderer extension at the beginning of 
your script, if native drawing mode is desired.
</p>
<!-- How glScript works end -->

<div class="footer">
OpenGL is a registered trademark of Silicon Graphics, Inc.
</div>
</body>
</html>
